package contracts.subjectiveQuiz

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method 'GET'
        url value(consumer(regex('/api/v3/subjectiveQuizzes/[0-9]+')), producer('/api/v3/subjectiveQuizzes/1'))
        headers {
            header('Content-Type', 'application/json;charset=UTF-8')
        }
    }
    response {
        status 200
        body("""
            {
                "id": 1,
                "description": "subjective1",
                "makerId": 1,
                "referenceNumber": 1,
                "isAvailable": true,
                "quizGroupId": 1,
                "createTime": "2018-09-12 06:19:04.0",
                "updateTime": "2018-09-12 06:19:04.0",
                "remark": "remark1",
                "tags": [],
            } 
        """)
        bodyMatchers {
            jsonPath('$', byType())
            jsonPath('$.id', byRegex(number()))
            jsonPath('$.description', byRegex("[\\s\\S]+"))
            jsonPath('$.makerId', byRegex(number()))
            jsonPath('$.referenceNumber', byRegex(number()))
            jsonPath('$.isAvailable', byRegex(anyBoolean()))
            jsonPath('$.quizGroupId', byRegex(number()))
            jsonPath('$.createTime', byRegex("[\\s\\S]+"))
            jsonPath('$.updateTime', byRegex("[\\s\\S]+"))
            jsonPath('$.remark', byRegex("[\\s\\S]+"))
            jsonPath('$.tags', byType())
        }
        headers {
            header('Content-Type', 'application/json;charset=UTF-8')
        }
    }
}

